//
//  WmcModifyTimeTipView.swift
//  YPWatermarkCamera
//
//  Created by 周诗松 on 2022/7/4.
//

import UIKit

class WmcModifyTimeTipView: WmcBaseView {
    // Internal
    
    override var isHidden: Bool {
        didSet {
            if isHidden {
                WmcTaskSchedulerManager.resetPauseStatus(type: .forbidEditDateTip)
            }
        }
    }

    var dismissClosure: (() -> Void)?

    override func makeUI() {
        layer.shadowColor = UIColor.wmc_grayH13_ACAEAF.cgColor
        layer.shadowOpacity = 1.0
        layer.shadowOffset = CGSize(width: 0, height: 0)
        layer.shadowRadius = 4
        layer.cornerRadius = 8
        addSubview(tipLabel)
        addSubview(closeBtn)

        tipLabel.snp.makeConstraints { make in
            make.left.right.equalToSuperview()
            make.centerX.centerY.equalToSuperview()
        }

        closeBtn.snp.makeConstraints { make in
            make.width.height.equalTo(20)
            make.top.equalTo(8)
            make.right.equalTo(-8)
        }
    }

    override func bindViewAction() {
        closeBtn.yp.addEvent { [weak self] _ in
            guard let weakSelf = self else { return }
            weakSelf.dismiss()
        }
    }

    func dismiss() {
        isHidden = true
        dismissClosure?()
        dismissClosure = nil
    }

    // Private

    private lazy var tipLabel: UILabel = {
        let label = UILabel()
        label.text = "本相机不能修改时间"
        label.font = UIFont.systemFont(ofSize: 22, weight: .semibold)
        label.textColor = .wmc_grayH2_323233
        label.textAlignment = .center
        return label
    }()

    private lazy var closeBtn: UIButton = {
        let btn = UIButton(type: .custom)
        btn.setImage("close".wmc_image, for: .normal)
        btn.imageEdgeInsets = UIEdgeInsets(top: 1, left: 1, bottom: 1, right: 1)
        return btn
    }()
}
